﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SQLite;

namespace AFT2
{
    [Serializable]
    public class SearchesDataObject
    {   
        public SearchesDataObject(string id, string search, string date) {
            ID = id;
            Search = search;
            Date = date;
        }

        public string ID { get; set; }
        public string Search { get; set; }
        public string Date { get; set; }
    }

    [Serializable]
    public class SearchesDataList {

        public List<SearchesDataObject> data;
        public SearchesDataList() { 

            this.data = new List<SearchesDataObject>();
            SQLiteConnection myConnection = new SQLiteConnection();
            myConnection.ConnectionString = "Data Source=db\\phoneData.db";
            myConnection.Open();
            SQLiteCommand sqlcmd = new SQLiteCommand(myConnection);
            sqlcmd.CommandText = "select * from searches";
            SQLiteDataReader reader = sqlcmd.ExecuteReader();
            while(reader.Read()){         
                this.data.Add(new SearchesDataObject(
                        "" + reader["s_id"],
                        "" + reader["search"],
                        "" + reader["date"]                    
                    ));

            }        
        }
    }


}
